﻿@using WebApplication1.Models;
@using WebApplication1.Models.Database;
@{
    ViewData["Title"] = "index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var classifications = ViewData["classification"] as List<Classification>;
    var news = ViewData["news"] as List<News>;
    var cid = (int)ViewData["cid"];
    var pagemax =Convert.ToInt32(ViewData["pagemax"]);
    //var page = ViewData["page"] as List<News>;
    var page =Convert.ToInt32(ViewData["page"]);
    var page1 = page;
}
<div id="main">
      
    @{


        int row;
        if (news.Count % 2 == 0)
        {
            row = news.Count / 2;
        }
        else
        {
            row = news.Count + 1;
        }

        for(var i = page*3-2; i <=news.Count&&i<=page*3 ; i++)
        {
            <ul id="main_ul">
                @{
                    var list =news.Skip((i - 1) * 2).Take(2).ToList();
                        foreach(var item in list)
                    {
                        <li>
                            <a href="detail.html?id=@item.Id">
                            <img src="@item.Imgpath">
                            <p>@item.Title</p>
                            <p>@item.Content</p>
                            <p>发布时间：@item.Update</p>
                            </a>
                        </li>
                    }
                }
            </ul>
        }

    }

</div>

@{
    <div class="paging">
        <ul class="pagination">
            @{

                if (page1 == 1)
                {
                    <li><a href="index.html?page=1">«</a></li>
                }else{
                    <li><a href="index.html?page=@(page1-1)">«</a></li>
                }
        }
            
    @{
        for(int i = 1; i <= pagemax; i++)
    {
        <li><a class="active" href="index.html?page=@i">@i</a></li>
    }
}
            @{
                if (page1 == pagemax)
                {
                    <li><a href="index.html?page=@pagemax">»</a></li>
                }else{
                    <li><a href="index.html?page=@(page+1)">»</a></li>
                }
        }
   
    </ul>
    </div>
}
    
  

